#!/bin/bash

host=$1

function amp {
  echo "============================================="
  call=http://$host/amp/0/$1
  echo $call
  curl $call
  echo
}

function dogvibes {
  echo "============================================="
  call=http://$host/dogvibes/$1
  echo $call
  curl $call
  echo
}

dogvibes "search?query=memories"

# NOTE: requires that dogvibes.db is removed prior to server startup for
# intended result. When JSON parsing is included here we can make smarter
# decisions...
dogvibes "createPlaylist?name=My%20Favourites"
dogvibes "createPlaylist?name=More&20Music"
dogvibes "getAllPlaylists"
dogvibes "addTrackToPlaylist?playlist_id=1&uri=spotify:track:3A3WCIkkm5MqGRnc4LT6fz"
dogvibes "addTrackToPlaylist?playlist_id=1&uri=spotify:track:0S3gpZzlT9Hb7CCSV2owX7"
dogvibes "addTrackToPlaylist?playlist_id=1&uri=spotify:track:5WO8Vzz5hFWBGzJaNI5U5n"
dogvibes "addTrackToPlaylist?playlist_id=2&uri=spotify:track:5WO8Vzz5hFWBGzJaNI5U5n"
dogvibes "getAllTracksInPlaylist?playlist_id=1"
dogvibes "removeTrackFromPlaylist?playlist_id=1&track_id=1"
dogvibes "getAllTracksInPlaylist?playlist_id=1"
dogvibes "removePlaylist?id=1"
dogvibes "getAllPlaylists"

amp "queue?uri=spotify:track:3A3WCIkkm5MqGRnc4LT6fz"
amp "queue?uri=spotify:track:3ZlFUr0RBrUYYsmlcFvD0e"
amp "queue?uri=spotify:track:3q50J3nI1GOjDOwZDjt5Un"
amp "queue?uri=spotify:track:0S3gpZzlT9Hb7CCSV2owX7"
amp "queue?uri=spotify:track:69xL3vzKISEij96FrmWYNF"
amp "queue?uri=spotify:track:3Qvf812dY5JVlaZEbzI3nZ"
amp "queue?uri=spotify:track:7kXmJwrZGIhDaLT9sNo3ut"
amp "queue?uri=spotify:track:7rk75X26LwTEE8slwrqMjy"
amp "queue?uri=spotify:track:5WO8Vzz5hFWBGzJaNI5U5n"

amp "getAllTracksInQueue"
#amp "removeFromQueue?nbr=0"
amp "getAllTracksInQueue"

amp "play"
sleep 2

amp "getStatus"

amp "connectSpeaker?nbr=0"
sleep 2

amp "setVolume?level=0.1"
sleep 2
amp "setVolume?level=0.5"
sleep 2
amp "setVolume?level=1.0"
sleep 2

amp "nextTrack"
amp "getQueuePosition"
sleep 2

amp "nextTrack"
amp "getQueuePosition"
sleep 2

amp "previousTrack"
amp "getQueuePosition"
sleep 2

amp "playTrack?nbr=8"
amp "getQueuePosition"
sleep 2

amp "pause"
sleep 2

amp "play"

amp "getPlayedMilliSeconds"
sleep 1
amp "getPlayedMilliSeconds"
sleep 1
amp "getPlayedMilliSeconds"
sleep 1

amp "seek?mseconds=30000"
amp "getPlayedMilliSeconds"
sleep 2
amp "seek?mseconds=2000"
amp "getPlayedMilliSeconds"
sleep 2

amp "disconnectSpeaker?nbr=0"
sleep 2

amp stop
sleep 2
